using System;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CBaseMessageInfo : CBaseTable
    {
        //
        public const string ENTITY_NAME = "tb_sys_message_info";
        public const string ENTITY_ALIAS = "messages";
        public const string ENTITY_KEY = "msg_id";
        public const string ENTITY_SYMBOL = "msg_name";
        //
        public const string ITEM_VALUE = "item_value";
        public const string ITEM_ARGS = "item_args";
        public const string ITEM_LEVEL = "item_level";
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        //
        private SBaseMessageInfo _ = null;
        //
        public CBaseMessageInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseMessageInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseMessageInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CBaseMessageInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SBaseMessageInfo());
        }
        protected void SetSchema(SBaseMessageInfo s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            this._DataTable.Columns.Add(ITEM_VALUE, typeof(string)).MaxLength = 1024;
            this._DataTable.Columns.Add(ITEM_ARGS, typeof(string)).MaxLength = 128;
            this._DataTable.Columns.Add(ITEM_LEVEL, typeof(int)).DefaultValue = this._.ItemLevel;
            this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
        }
        //
        #region Property
        //
        public string ItemValue
        {
            set
            {
                this._.ItemValue = value;
                this.SetValue(ITEM_VALUE, value);
            }
            get
            {
                return this._.ItemValue;
            }
        }
        //
        public string ItemArgs
        {
            set
            {
                this._.ItemArgs = value;
                this.SetValue(ITEM_ARGS, value);
            }
            get
            {
                return this._.ItemArgs;
            }
        }
        //
        public int ItemLevel
        {
            set
            {
                this._.ItemLevel = value;
                this.SetValue(ITEM_LEVEL, value);
            }
            get
            {
                return this._.ItemLevel;
            }
        }
        //
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.ItemValue = this.GetValue<string>(ITEM_VALUE);
            this._.ItemArgs = this.GetValue<string>(ITEM_ARGS);
            this._.ItemLevel = this.GetValue<int>(ITEM_LEVEL);
            this._.UserID = this.GetValue<long>(USER_ID);
            return true;
        }
        //
    }
    //
    public class SBaseMessageInfo : SBaseTable
    {
        //
        public string ItemValue = null;
        public string ItemArgs = null;
        public int ItemLevel = 0;
        public long UserID = -1;
        //
    }
    //
}
//
